

#include "../lib/serversocket.h"
#include <iostream>
#include "../lib/exceptions.h"


int main(){

    try
    {
        //Something that throws an exception
        ServerSocket ss; //test the constructor
    }
    catch( BaseException* e )
    {
        //code that handles exception
        std::cout << "Error: " << e->what() << std::endl;
    }

    ServerSocket s1;  //we need at least a socket to test (pending the constructor worked above)

    try
    {
        //Something that throws an exception
        s1.acceptSocket( ); //try acceptSocket
    }
    catch( BaseException* e )
    {
        //code that handles exception
        std::cout << "Error: " << e->what() << std::endl;
    }

    try
    {
        //Something that throws an exception
        s1.acceptSocket( struct timeval 20); //try acceptSocket with struct
    }
    catch( BaseException* e )
    {
        //code that handles exception
        std::cout << "Error: " << e->what() << std::endl;
    }

    try
    {
        //Something that throws an exception
        s1.findAndBind();  //test findAndBind
    }
    catch( BaseException* e )
    {
        //code that handles exception
        std::cout << "Error: " << e->what() << std::endl;
        std::cout<< "The listening port is:"<<s1.getPort()<<std::endl;  //test getPort()
    }


    //need to find a way to test accept and findandbind


    //std::cout<<"Socket is " <<ss.getPort()<<std::endl;
}
